package collections;

import java.util.*;

public class Sort1 implements Comparator
{
    public int compare(Object o1, Object o2)
    {
        String s1 = (String) o1;
        String s2 = (String) o2;

        return s1.toLowerCase().compareTo(s2.toLowerCase());
    }

    public static void main(String args[])
    {
        List list = new ArrayList();

        list.add("abc");
        list.add("DEF");
        list.add("ghi");

        // standard sort

        Collections.sort(list);
        Iterator iter = list.iterator();
        while (iter.hasNext())
            System.out.println(iter.next());

        // sort, ignoring case

        Collections.sort(list, new Sort1());
        iter = list.iterator();
        while (iter.hasNext())
            System.out.println(iter.next());
    }
}
